import pymongo
import json
from bson import json_util
HOST = '127.0.0.1'
PORT = 27017
DBNAME = 'storage'
def FetchRules():
    conn = pymongo.Connection(HOST,PORT)
    db = conn[DBNAME]
    cursor = db.rule_model.find()
    jsonrules = []
    
    for doc in cursor:
        rule = json.dumps(doc,default=json_util.default)
        jsonrules.append(rule)
    #docs = [json.loads(cursor, object_hook=json_util.object_hook) for j_doc in json_docs]
    return jsonrules



		
if __name__ == "__main__":
    print FetchRules()
